﻿using System;

namespace Program09
{
    class Program
    {
        static void Main(string[] args)
        {
            //使用递归实现求和1-n的和
            Console.WriteLine("1...4的和为" + GetSum(4));
        }
        public static int GetSum(int n)
        {
            if (n == 1)
                return 1;
            //递归调用自己
            int tmp = GetSum(n - 1);
            return tmp + n;
        }
    }
}
